//
// Created by Mzoro on 2022/4/19.
//
#include <stddef.h>
#include <string.h>
#include "includes/includes.h"

struct node *search(char *word, struct node *p) {

    if (p == NULL) {
        p = talloc();
        p->word = cpword(word);
        p->count = 1;
        p->left = p->right = NULL;
    } else if (strcmp(word, p->word) < 0) {
        p->left = search(word, p->left);
    } else if (strcmp(word, p->word) > 0) {
        p->right = search(word, p->right);
    } else {
        p->count++;
    }
    return p;
}
